package org.example.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.example.config.R;
import org.example.domain.Car;
import org.example.domain.Product;
import org.example.service.CarService;
import org.example.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("product")
public class ProductController {
    @Autowired
    ProductService productService;

    @PostMapping("productList")
    public R productList(Page page, @RequestBody Product product){
        PageHelper.startPage((int) page.getCurrent(), (int) page.getSize());
        List<Product> list = productService.productList(product);
        PageInfo<Product> productPageInfo = new PageInfo<>(list);
        return R.successed(productPageInfo);
    }

/*    @PostMapping("getById")
    public R getById(Integer id){
        Product product = productService.getById(id);
        return R.successed(product.getId());
    }*/

//    @RequestMapping("del")
//    public R del(Integer id){
//        return productService.del(id);
//    }
}
